package com.seecen.HJM.config;


import com.seecen.HJM.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@Component
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 登录接口和注册接口不拦截
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**") // 拦截所有请求
                .excludePathPatterns(
                        "/admin/user/login/**",
                        "/api/captcha/**",
                        "/api/admin/**",
                        "/admin/**", "admin/user/sendVerificationCode", "/admin/user/resetUserPassword",
                        "/api/feedback/getFeedback",
                        "/api/feedback//deleteFeedback/{id}",
                        "/api/feedback/deleteFeedbackList",
                        "/api/banner/**",
                        "/admin/login", "/admin/logout", "/admin/register",
                        "/user/login", "/user/logout", "/user/register",
                        "/user/sendVerificationCode", "/user/resetUserPassword",
                        "/banner/getBannerList",
                        "/playlist/**",
                        "/playlist-binding/**",
                        "/playlist/getAllPlaylists", "/playlist/getRecommendedPlaylists", "/playlist/getPlaylistDetail/**",
                        "/artist/getAllArtists", "/artist/getArtistDetail/**",
                        "/song/getAllSongs", "/song/getRecommendedSongs", "/song/getSongDetail/**", "/song/getSongDetail/*"
                /*
                用户相关
                // /admin/user/sendVerificationCode  邮箱验证码（忘记密码）
                /admin/user/resetUserPassword  用户忘记密码
                /admin/user/registerUser  用户注册
                /admin/user/login/username 用户登录
                /api/captcha//arithmetic  图形验证码
                /api/captcha/emailCode   邮箱验证码（注册）
                 */
                );
    }

}

